package com.holly.unit.bpmn.activiti.ext;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.holly.unit.bpmn.activiti.entity.ActivitiExpression;
import com.holly.unit.bpmn.activiti.mapper.ActivitiExpressionMapper;
import com.holly.unit.bpmn.activiti.pojo.ActiviExpressionRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ActiviExpressionService extends ServiceImpl<ActivitiExpressionMapper, ActivitiExpression> {

    @Autowired
    private ActivitiExpressionMapper activitiExpressionMapper;

    public void addNode(List<ActivitiExpression> expressions) {
        this.saveBatch(expressions);
    }

    public List<ActivitiExpression> getExpression(ActiviExpressionRequest activiExpressionRequest) {
        LambdaQueryWrapper<ActivitiExpression> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(ActivitiExpression::getNodeId, activiExpressionRequest.getNodeId());
        queryWrapper.in(ActivitiExpression::getModelId, activiExpressionRequest.getModelId());
        return activitiExpressionMapper.selectList(queryWrapper);
    }

    public void removeNode(String nodelId, String modelId) {
        LambdaQueryWrapper<ActivitiExpression> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(ActivitiExpression::getNodeId,nodelId);
        queryWrapper.in(ActivitiExpression::getModelId,modelId);
        this.remove(queryWrapper);
    }
}
